package cn.jekun.shop.web.action;


import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import net.sf.json.DateJsonValueProcessor;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import cn.jekun.shop.common.service.OpenedCityService;
import cn.jekun.shop.common.service.ShopBaseAction;
/**
 * 已开通城市
 * @author twj
 *
 */
@SuppressWarnings("serial")
public class OpenedCityAction extends ShopBaseAction{
	@Resource(name = OpenedCityService.BEAN_NAME)
	protected OpenedCityService openedCityService;
	/**
	 * 已开通城市列表
	 * @return
	 */
	public String openedCityList(){
		JSONArray json = new JSONArray();
		JsonConfig jsonConfig = new JsonConfig();
		jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); 
		json = JSONArray.fromObject(this.openedCityService.queryCitys(), jsonConfig);
		return this.writeJson(json);
	}
	/**
	 * 查询已开通城市的区域
	 * @return
	 */
	public String regionList(){
		String cityId = this.request.getParameter("cityId");
		JSONObject json = new JSONObject();
		json = this.openedCityService.queryRegion(cityId);
		return this.writeJson(json);
	}
	/**
	 * 距离
	 * @return
	 */
	public String distance(){
		JSONObject json = new JSONObject();
		List<String> list = new ArrayList<String>();
		list.add("500");
		list.add("1000");
		list.add("5000");
		list.add("10000");
		list.add("20000");
		json.put("distanceList", list);
		return this.writeJson(json);
	}
	

}
